DECLARE processCursor CURSOR FOR
SELECT spid
FROM sysprocesses INNER JOIN sysdatabases
ON sysprocesses.dbid = sysdatabases.dbid
WHERE sysdatabases.name = {0}

DECLARE @processId smallint

OPEN processCursor
FETCH NEXT FROM processCursor INTO @processId
WHILE (@@FETCH_STATUS = 0)
BEGIN
    EXEC ('KILL ' + @processId)
    FETCH NEXT FROM processCursor INTO @processId
END    

CLOSE processCursor
DEALLOCATE processCursor

